// clmysql.h: interface for the CLMySql class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_MYSQL_H__69785183_86C3_4087_90B6_4F9D0FC78061__INCLUDED_)
#define AFX_MYSQL_H__69785183_86C3_4087_90B6_4F9D0FC78061__INCLUDED_

#ifdef _WIN32
#include <windows.h>
#include <mysql.h>		// the mysql's header
#else
#include <mysql/mysql.h>
#endif
#include "str.h"	// Added by ClassView
#include "log.h"	// Added by ClassView
#include "config.h"
#include "sql.h"

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class CLMySql:public CLSql
{
public:
	CLMySql(LPCSTR conf_file);
	CLMySql(LPCSTR server,LPCSTR user,LPCSTR pass,LPCSTR name,LPCSTR port="3306",LPCSTR unixsocket=NULL);
	CLMySql();
	~CLMySql();
	int open();
	int init(const CLConfig& conf);
	int init(LPCSTR server,LPCSTR user,LPCSTR pass,LPCSTR name,LPCSTR port="3306",LPCSTR unixsocket=NULL);

	int  query(LPCSTR sql,CLStr& result,int with_field=0);
	void close();
	static	CLStr passwd(LPCSTR pass);
	static  CLStr unpass(LPCSTR pass);

private:
	CLStr m_server,m_user,m_pass,m_name,m_port,m_unixsocket;
	MYSQL m_mysql,*m_pmysql;
};

#endif // !defined(AFX_MYSQL_H__69785183_86C3_4087_90B6_4F9D0FC78061__INCLUDED_)
